home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / PROC_FS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  12KB  |  467 lines

  1. #ifndef _LINUX_PROC_FS_H
  2. #define _LINUX_PROC_FS_H
  3.  
  4. #include <linux/config.h>
  5. #include <linux/malloc.h>
  6.  
  7. /*
  8.  * The proc filesystem constants/structures
  9.  */
  10.  
  11. /*
  12.  * We always define these enumerators
  13.  */
  14.  
  15. enum root_directory_inos {
  16.     PROC_ROOT_INO = 1,
  17.     PROC_LOADAVG,
  18.     PROC_UPTIME,
  19.     PROC_MEMINFO,
  20.     PROC_KMSG,
  21.     PROC_VERSION,
  22.     PROC_CPUINFO,
  23.     PROC_PCI,
  24.     PROC_MCA,
  25.     PROC_NUBUS,
  26.     PROC_SELF,    /* will change inode # */
  27.     PROC_NET,
  28.         PROC_SCSI,
  29.     PROC_MALLOC,
  30.     PROC_KCORE,
  31.     PROC_MODULES,
  32.     PROC_STAT,
  33.     PROC_DEVICES,
  34.     PROC_PARTITIONS,
  35.     PROC_INTERRUPTS,
  36.     PROC_FILESYSTEMS,
  37.     PROC_KSYMS,
  38.     PROC_DMA,    
  39.     PROC_IOPORTS,
  40.     PROC_PROFILE, /* whether enabled or not */
  41.     PROC_CMDLINE,
  42.     PROC_SYS,
  43.     PROC_MTAB,
  44.     PROC_SWAP,
  45.     PROC_MD,
  46.     PROC_RTC,
  47.     PROC_LOCKS,
  48.     PROC_HARDWARE,
  49.     PROC_SLABINFO,
  50.     PROC_PARPORT,
  51.     PROC_PPC_HTAB,
  52.     PROC_STRAM,
  53.     PROC_SOUND,
  54.     PROC_MTRR, /* whether enabled or not */
  55.     PROC_FS
  56. };
  57.  
  58. enum pid_directory_inos {
  59.     PROC_PID_INO = 2,
  60.     PROC_PID_STATUS,
  61.     PROC_PID_MEM,
  62.     PROC_PID_CWD,
  63.     PROC_PID_ROOT,
  64.     PROC_PID_EXE,
  65.     PROC_PID_FD,
  66.     PROC_PID_ENVIRON,
  67.     PROC_PID_CMDLINE,
  68.     PROC_PID_STAT,
  69.     PROC_PID_STATM,
  70.     PROC_PID_MAPS,
  71. #if CONFIG_AP1000
  72.     PROC_PID_RINGBUF,
  73. #endif
  74.     PROC_PID_CPU,
  75. };
  76.  
  77. enum pid_subdirectory_inos {
  78.     PROC_PID_FD_DIR = 0x8000,    /* 0x8000-0xffff */
  79. };
  80.  
  81. enum net_directory_inos {
  82.     PROC_NET_UNIX = 128,
  83.     PROC_NET_ARP,
  84.     PROC_NET_ROUTE,
  85.     PROC_NET_DEV,
  86.     PROC_NET_RAW,
  87.     PROC_NET_RAW6,
  88.     PROC_NET_TCP,
  89.     PROC_NET_TCP6,
  90.     PROC_NET_UDP,
  91.     PROC_NET_UDP6,
  92.     PROC_NET_SNMP,
  93.     PROC_NET_RARP,
  94.     PROC_NET_IGMP,
  95.     PROC_NET_IPMR_VIF,
  96.     PROC_NET_IPMR_MFC,
  97.     PROC_NET_IPFWFWD,
  98.     PROC_NET_IPFWIN,
  99.     PROC_NET_IPFWOUT,
  100.     PROC_NET_IPACCT,
  101.     PROC_NET_IPMSQHST,
  102.     PROC_NET_WIRELESS,
  103.     PROC_NET_IPX_INTERFACE,
  104.     PROC_NET_IPX_ROUTE,
  105.     PROC_NET_IPX,
  106.     PROC_NET_ATALK,
  107.     PROC_NET_AT_ROUTE,
  108.     PROC_NET_ATIF,
  109.     PROC_NET_AX25_ROUTE,
  110.     PROC_NET_AX25,
  111.     PROC_NET_AX25_CALLS,
  112.     PROC_NET_BMAC,
  113.     PROC_NET_NR_NODES,
  114.     PROC_NET_NR_NEIGH,
  115.     PROC_NET_NR,
  116.     PROC_NET_SOCKSTAT,
  117.     PROC_NET_SOCKSTAT6,
  118.     PROC_NET_RTCACHE,
  119.     PROC_NET_AX25_BPQETHER,
  120.     PROC_NET_IP_MASQ_APP,
  121.     PROC_NET_RT6,
  122.     PROC_NET_SNMP6,
  123.     PROC_NET_RT6_STATS,
  124.     PROC_NET_NDISC,
  125.     PROC_NET_STRIP_STATUS,
  126.     PROC_NET_STRIP_TRACE,
  127.     PROC_NET_Z8530,
  128.     PROC_NET_RS_NODES,
  129.     PROC_NET_RS_NEIGH,
  130.     PROC_NET_RS_ROUTES,
  131.     PROC_NET_RS,
  132.     PROC_NET_CL2LLC,
  133.     PROC_NET_X25_ROUTES,
  134.     PROC_NET_X25,
  135.     PROC_NET_TR_RIF,
  136.     PROC_NET_DN_DEV,
  137.     PROC_NET_DN_ADJ,
  138.     PROC_NET_DN_L1,
  139.     PROC_NET_DN_L2,
  140.     PROC_NET_DN_CACHE,
  141.     PROC_NET_DN_SKT,
  142.     PROC_NET_DN_FW,
  143.     PROC_NET_DN_RAW,
  144.     PROC_NET_NETSTAT,
  145.     PROC_NET_IPFW_CHAINS,
  146.     PROC_NET_IPFW_CHAIN_NAMES,
  147.     PROC_NET_AT_AARP,
  148.     PROC_NET_BRIDGE,
  149.     PROC_NET_LAST
  150. };
  151.  
  152. enum scsi_directory_inos {
  153.     PROC_SCSI_SCSI = 256,
  154.     PROC_SCSI_ADVANSYS,
  155.     PROC_SCSI_PCI2000,
  156.     PROC_SCSI_PCI2220I,
  157.     PROC_SCSI_PSI240I,
  158.     PROC_SCSI_EATA,
  159.     PROC_SCSI_EATA_PIO,
  160.     PROC_SCSI_AHA152X,
  161.     PROC_SCSI_AHA1542,
  162.     PROC_SCSI_AHA1740,
  163.     PROC_SCSI_AIC7XXX,
  164.     PROC_SCSI_BUSLOGIC,
  165.     PROC_SCSI_U14_34F,
  166.     PROC_SCSI_FDOMAIN,
  167.     PROC_SCSI_GDTH,
  168.     PROC_SCSI_GENERIC_NCR5380,
  169.     PROC_SCSI_IN2000,
  170.     PROC_SCSI_PAS16,
  171.     PROC_SCSI_QLOGICFAS,
  172.     PROC_SCSI_QLOGICISP,
  173.     PROC_SCSI_QLOGICFC,
  174.     PROC_SCSI_SEAGATE,
  175.     PROC_SCSI_T128,
  176.     PROC_SCSI_NCR53C7xx,
  177.     PROC_SCSI_SYM53C8XX,
  178.     PROC_SCSI_NCR53C8XX,
  179.     PROC_SCSI_ULTRASTOR,
  180.     PROC_SCSI_7000FASST,
  181.     PROC_SCSI_IBMMCA,
  182.     PROC_SCSI_FD_MCS,
  183.     PROC_SCSI_EATA2X,
  184.     PROC_SCSI_DC390T,
  185.     PROC_SCSI_AM53C974,
  186.     PROC_SCSI_SSC,
  187.     PROC_SCSI_NCR53C406A,
  188.     PROC_SCSI_SYM53C416,
  189.     PROC_SCSI_MEGARAID,
  190.     PROC_SCSI_PPA,
  191.     PROC_SCSI_ATP870U,
  192.     PROC_SCSI_ESP,
  193.     PROC_SCSI_QLOGICPTI,
  194.     PROC_SCSI_AMIGA7XX,
  195.     PROC_SCSI_MVME16x,
  196.     PROC_SCSI_BVME6000,
  197.     PROC_SCSI_A3000,
  198.     PROC_SCSI_A2091,
  199.     PROC_SCSI_GVP11,
  200.     PROC_SCSI_ATARI,
  201.     PROC_SCSI_MAC,
  202.     PROC_SCSI_IDESCSI,
  203.     PROC_SCSI_MESH,
  204.     PROC_SCSI_53C94,
  205.     PROC_SCSI_PLUTO,
  206.     PROC_SCSI_INI9100U,
  207.      PROC_SCSI_INIA100,
  208.     PROC_SCSI_FCAL,
  209.     PROC_SCSI_SCSI_DEBUG,    
  210.     PROC_SCSI_NOT_PRESENT,
  211.     PROC_SCSI_FILE,                        /* I'm assuming here that we */
  212.     PROC_SCSI_LAST = (PROC_SCSI_FILE + 16) /* won't ever see more than */
  213. };                                             /* 16 HBAs in one machine   */
  214.  
  215. enum mca_directory_inos {
  216.     PROC_MCA_MACHINE = (PROC_SCSI_LAST+1),
  217.     PROC_MCA_REGISTERS,
  218.     PROC_MCA_VIDEO,
  219.     PROC_MCA_SCSI,
  220.     PROC_MCA_SLOT,    /* the 8 adapter slots */
  221.     PROC_MCA_LAST = (PROC_MCA_SLOT + 8)
  222. };
  223.  
  224. enum bus_directory_inos {
  225.     PROC_BUS_PCI = PROC_MCA_LAST,
  226.     PROC_BUS_PCI_DEVICES,
  227.     PROC_BUS_ZORRO,
  228.     PROC_BUS_ZORRO_DEVICES,
  229.     PROC_BUS_LAST
  230. };
  231.  
  232. enum fs_directory_inos {
  233.     PROC_FS_CODA = PROC_BUS_LAST,
  234.     PROC_FS_LAST
  235. };
  236.  
  237. enum fs_coda_directory_inos {
  238.     PROC_VFS_STATS = PROC_FS_LAST,
  239.     PROC_UPCALL_STATS,
  240.     PROC_PERMISSION_STATS,
  241.     PROC_CACHE_INV_STATS,
  242.     PROC_CODA_FS_LAST
  243. };
  244.  
  245. /* Finally, the dynamically allocatable proc entries are reserved: */
  246.  
  247. #define PROC_DYNAMIC_FIRST 4096
  248. #define PROC_NDYNAMIC      4096
  249. #define PROC_OPENPROM_FIRST (PROC_DYNAMIC_FIRST+PROC_NDYNAMIC)
  250. #define PROC_OPENPROM       PROC_OPENPROM_FIRST
  251. #define PROC_NOPENPROM       4096
  252. #define PROC_OPENPROMD_FIRST (PROC_OPENPROM_FIRST+PROC_NOPENPROM)
  253. #define PROC_NOPENPROMD       4096
  254.  
  255. #define PROC_SUPER_MAGIC 0x9fa0
  256.  
  257. /*
  258.  * This is not completely implemented yet. The idea is to
  259.  * create an in-memory tree (like the actual /proc filesystem
  260.  * tree) of these proc_dir_entries, so that we can dynamically
  261.  * add new files to /proc.
  262.  *
  263.  * The "next" pointer creates a linked list of one /proc directory,
  264.  * while parent/subdir create the directory structure (every
  265.  * /proc file has a parent, but "subdir" is NULL for all
  266.  * non-directory entries).
  267.  *
  268.  * "get_info" is called at "read", while "fill_inode" is used to
  269.  * fill in file type/protection/owner information specific to the
  270.  * particular /proc file.
  271.  */
  272. struct proc_dir_entry {
  273.     unsigned short low_ino;
  274.     unsigned short namelen;
  275.     const char *name;
  276.     mode_t mode;
  277.     nlink_t nlink;
  278.     uid_t uid;
  279.     gid_t gid;
  280.     unsigned long size;
  281.     struct inode_operations * ops;
  282.     int (*get_info)(char *, char **, off_t, int, int);
  283.     void (*fill_inode)(struct inode *, int);
  284.     struct proc_dir_entry *next, *parent, *subdir;
  285.     void *data;
  286.     int (*read_proc)(char *page, char **start, off_t off,
  287.              int count, int *eof, void *data);
  288.     int (*write_proc)(struct file *file, const char *buffer,
  289.               unsigned long count, void *data);
  290.     int (*readlink_proc)(struct proc_dir_entry *de, char *page);
  291.     unsigned int count;    /* use count */
  292.     int deleted;        /* delete flag */
  293. };
  294.  
  295. typedef    int (read_proc_t)(char *page, char **start, off_t off,
  296.               int count, int *eof, void *data);
  297. typedef    int (write_proc_t)(struct file *file, const char *buffer,
  298.                unsigned long count, void *data);
  299.  
  300. extern int (* dispatch_scsi_info_ptr) (int ino, char *buffer, char **start,
  301.                 off_t offset, int length, int inout);
  302.  
  303. #ifdef CONFIG_PROC_FS
  304.  
  305. extern struct proc_dir_entry proc_root;
  306. extern struct proc_dir_entry proc_root_fs;
  307. extern struct proc_dir_entry *proc_net;
  308. extern struct proc_dir_entry *proc_scsi;
  309. extern struct proc_dir_entry proc_sys;
  310. extern struct proc_dir_entry proc_openprom;
  311. extern struct proc_dir_entry proc_pid;
  312. extern struct proc_dir_entry proc_pid_fd;
  313. extern struct proc_dir_entry proc_mca;
  314. extern struct proc_dir_entry *proc_bus;
  315.  
  316. extern struct inode_operations proc_scsi_inode_operations;
  317.  
  318. extern void proc_root_init(void);
  319. extern void proc_base_init(void);
  320.  
  321. extern int proc_register(struct proc_dir_entry *, struct proc_dir_entry *);
  322. extern int proc_unregister(struct proc_dir_entry *, int);
  323.  
  324. static inline int proc_net_register(struct proc_dir_entry * x)
  325. {
  326.     return proc_register(proc_net, x);
  327. }
  328.  
  329. static inline int proc_net_unregister(int x)
  330. {
  331.     return proc_unregister(proc_net, x);
  332. }
  333.  
  334. static inline int proc_scsi_register(struct proc_dir_entry *driver, 
  335.                      struct proc_dir_entry *x)
  336. {
  337.     x->ops = &proc_scsi_inode_operations;
  338.     if(x->low_ino < PROC_SCSI_FILE){
  339.     return(proc_register(proc_scsi, x));
  340.     }else{
  341.     return(proc_register(driver, x));
  342.     }
  343. }
  344.  
  345. static inline int proc_scsi_unregister(struct proc_dir_entry *driver, int x)
  346. {
  347.     extern void scsi_init_free(char *ptr, unsigned int size);
  348.  
  349.     if(x < PROC_SCSI_FILE)
  350.     return(proc_unregister(proc_scsi, x));
  351.     else {
  352.     struct proc_dir_entry **p = &driver->subdir, *dp;
  353.     int ret;
  354.  
  355.     while ((dp = *p) != NULL) {
  356.         if (dp->low_ino == x) 
  357.             break;
  358.         p = &dp->next;
  359.     }
  360.     ret = proc_unregister(driver, x);
  361.     scsi_init_free((char *) dp, sizeof(struct proc_dir_entry) + 4);
  362.     return(ret);
  363.     }
  364. }
  365.  
  366. extern struct dentry_operations proc_dentry_operations;
  367. extern struct super_block *proc_read_super(struct super_block *,void *,int);
  368. extern int init_proc_fs(void);
  369. extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
  370. extern int proc_statfs(struct super_block *, struct statfs *, int);
  371. extern void proc_read_inode(struct inode *);
  372. extern void proc_write_inode(struct inode *);
  373. extern int proc_permission(struct inode *, int);
  374.  
  375. extern int proc_match(int, const char *,struct proc_dir_entry *);
  376.  
  377. /*
  378.  * These are generic /proc routines that use the internal
  379.  * "struct proc_dir_entry" tree to traverse the filesystem.
  380.  *
  381.  * The /proc root directory has extended versions to take care
  382.  * of the /proc/<pid> subdirectories.
  383.  */
  384. extern int proc_readdir(struct file *, void *, filldir_t);
  385. extern int proc_lookup(struct inode *, struct dentry *);
  386.  
  387. struct openpromfs_dev {
  388.      struct openpromfs_dev *next;
  389.      u32 node;
  390.      ino_t inode;
  391.      kdev_t rdev;
  392.      mode_t mode;
  393.      char name[32];
  394. };
  395. extern struct inode_operations *
  396. proc_openprom_register(int (*readdir)(struct file *, void *, filldir_t),
  397.                int (*lookup)(struct inode *, struct dentry *),
  398.                void (*use)(struct inode *, int),
  399.                struct openpromfs_dev ***);
  400. extern void proc_openprom_deregister(void);
  401. extern void (*proc_openprom_use)(struct inode *,int);
  402. extern int proc_openprom_regdev(struct openpromfs_dev *);
  403. extern int proc_openprom_unregdev(struct openpromfs_dev *);
  404.   
  405. extern struct inode_operations proc_dir_inode_operations;
  406. extern struct inode_operations proc_file_inode_operations;
  407. extern struct inode_operations proc_net_inode_operations;
  408. extern struct inode_operations proc_netdir_inode_operations;
  409. extern struct inode_operations proc_openprom_inode_operations;
  410. extern struct inode_operations proc_mem_inode_operations;
  411. extern struct inode_operations proc_sys_inode_operations;
  412. extern struct inode_operations proc_array_inode_operations;
  413. extern struct inode_operations proc_arraylong_inode_operations;
  414. extern struct inode_operations proc_kcore_inode_operations;
  415. extern struct inode_operations proc_profile_inode_operations;
  416. extern struct inode_operations proc_kmsg_inode_operations;
  417. extern struct inode_operations proc_link_inode_operations;
  418. extern struct inode_operations proc_fd_inode_operations;
  419. #if CONFIG_AP1000
  420. extern struct inode_operations proc_ringbuf_inode_operations;
  421. #endif
  422. extern struct inode_operations proc_omirr_inode_operations;
  423. extern struct inode_operations proc_ppc_htab_inode_operations;
  424.  
  425. /*
  426.  * generic.c
  427.  */
  428. struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
  429.                      struct proc_dir_entry *parent);
  430. void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
  431.  
  432. /*
  433.  * proc_tty.c
  434.  */
  435. extern void proc_tty_init(void);
  436. extern void proc_tty_register_driver(struct tty_driver *driver);
  437. extern void proc_tty_unregister_driver(struct tty_driver *driver);
  438.  
  439. /*
  440.  * proc_devtree.c
  441.  */
  442. extern void proc_device_tree_init(void);
  443.  
  444. #else
  445.  
  446. extern inline int proc_register(struct proc_dir_entry *a, struct proc_dir_entry *b) {};
  447. extern inline int proc_unregister(struct proc_dir_entry *a, int b) {};
  448. extern inline int proc_net_register(struct proc_dir_entry *a) {};
  449. extern inline int proc_net_unregister(int x) {};
  450. extern inline int proc_scsi_register(struct proc_dir_entry *b, struct proc_dir_entry *c) {};
  451. extern inline int proc_scsi_unregister(struct proc_dir_entry *a, int x);
  452.  
  453. extern inline struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
  454.                      struct proc_dir_entry *parent)
  455. {
  456.     return NULL;
  457. }
  458.  
  459. extern inline void remove_proc_entry(const char *name, struct proc_dir_entry *parent) {};
  460.  
  461. extern inline void proc_tty_register_driver(struct tty_driver *driver) {};
  462. extern inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
  463.  
  464.  
  465. #endif
  466. #endif /* _LINUX_PROC_FS_H */
  467.